package itdfq.dfq.Behavior_Patters.zhongjiezhe;


import java.util.Hashtable;


/**
 * @Author GocChin
 * @Date 2021/5/17 19:00
 * @Blog: itdfq.com
 * @QQ: 909256107
 * @Descript:
 */
public class ChatGroup extends AbstractChatroom{
    private Hashtable map = new Hashtable();
    @Override
    public void register(Student student) {
        if (!map.contains(student)){
            map.put(student.getName(),student);
            student.setChatroom(this);
        }
    }

    @Override
    public void sendText(String from, String to, String abc) {
        Student o = (Student) map.get(to);

        //模拟不雅字符过滤
        abc= (String) map.replace("傻逼","***");
        o.receiveText(from,abc);
    }

    @Override
    public void sendImg(String from, String to, String image, Integer integer) {
        Student o = (Student) map.get(to);
        if (integer==1){
            System.out.println("对不起，您还不是vip无法发送图片，请充VIP");
        }else{
            if (image.length()<5){
                o.receiveImage(from,image);
            }else{
                if (integer==3){
                    o.receiveImage(from,image);
                }else{
                    System.out.println("对不起，你的vip级别不够，无法发送过大的图片，请充SVIP");
                }

            }
        }
    }
}
